package com.qf.adminService.impl;

import com.qf.adminDao.AdminGoodsDao;
import com.qf.adminService.AdminGoodsService;
import com.qf.pojo.Goods;
import com.qf.pojo.GoodsType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.adminService.impl
 * @Description:
 * @Date 2022/10/4 20:08
 */
@Service
public class AdminGoodsServiceImpl implements AdminGoodsService {
   @Autowired
    AdminGoodsDao adminGoodsDao;

    @Override
    public List<Goods> showAllGoods() {
        List<Goods> goods = adminGoodsDao.showAll();
        for (Goods good : goods) {
            good.setTypeName(adminGoodsDao.findById(good.getTypeid()).getName());
        }
        return goods;
    }

    @Override
    public List<GoodsType> showAllGoodsTypes() {
        List<GoodsType> typeList = adminGoodsDao.showAllGoodsTypes();
        return typeList;
    }

    @Override
    public void addGood(Goods goods) {
        adminGoodsDao.addGood(goods);
    }

    @Override
    public void addType(String typename, String goodsParent) {
        adminGoodsDao.addGoodType(typename,goodsParent);
    }
}
